package com.csj.cloud.common.vo;

import java.io.Serializable;
import java.text.MessageFormat;

public class ResultBean<T> implements Serializable {

    /**
     * 数据集
     */
    private T data = null;
    /**
     * 返回信息
     */
    private String msg = "Request Success！";
    /**
     * 业务自定义状态码
     */
    private Integer code = 1;
    /**
     * 是否更新
     */
    private String version;

    public ResultBean setErrorMsg(String errorMsg) {
        this.code = -1;
        this.msg = errorMsg;
        return this;
    }

    public void setErrorMsg(String errorPattern ,Object... params) {
        this.code =-1;
        this.msg = MessageFormat.format(errorPattern, params);
    }

    public void setSucMsg(T data) {
        this.code = 1;
        this.data = data;
    }


    public T getData() {
        return data;
    }

    public ResultBean<T> setData(T data) {
        this.data = data;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    @Override
    public String toString() {
        return "ResultBean [data=" + data + ", msg=" + msg + ", code=" + code + "]";
    }
}
